<template>
  <div>
    <FormPanel ref="from" :list="formList" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />
    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">取 消</el-button>
      <multiuse-button type="primary" v-if="this.rowData.dailyStatus == 60621004" :click="closeDrawer.bind(this, 2)">同 意</multiuse-button>
      <multiuse-button type="primary" v-if="this.rowData.dailyStatus == 60621005" :click="closeDrawer.bind(this, 2)">驳 回</multiuse-button>
    </div>
  </div>
</template>
<script>
import { submitByStatus } from '@/api/omSale/DealerDaily/DealerQaudit';
export default {
  data() {
    this.saveData = null;
    return {
      formList: this.createdFrom()
    };
  },
  components: {},
  props: ['type', 'rowData'],
  created() {
    this.formList[0].rules[0].required = this.rowData.dailyStatus == 60621005 ? true : false;
  },
  methods: {
    createdFrom() {
      return [
        {
          type: 'TEXT_AREA',
          label: '审批意见',
          fieldName: 'checkRemark',
          placeholder: '请输入',
          selfCols: 3,
          rules: [{ required: false, message: '请输入', trigger: 'blur' }]
        }
      ];
    },
    changeHandle(val) {
      this.saveData = val;
    },
    async closeDrawer(type) {
      if (type == 1) {
        this.$emit('close', false);
      } else {
        this.$refs.from.SUBMIT_FORM();
        if (this.saveData) {
          const res = await submitByStatus(Object.assign({}, this.rowData, this.saveData));

          if (res.resultCode == 200) {
            this.$notify.success({
              title: '提示信息',
              message: '操作成功'
            });
            this.$emit('close', false, 'refresh');
          } else {
            this.saveData = null;
          }
        }
      }
    }
  }
};
</script>
